﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Dazaza.Framework.Configuration
{
    //[XmlRoot("SqlConnConfig")]
    //public class SqlConnConfig
    //{
    //    [XmlElement("ConnStrs")]
    //    public ConnStrs ConnStrList { get; set; }
    //}
    //public class ConnStr
    //{
    //    [XmlText]
    //    public string Value { set; get; }
    //}
    //public class ConnStrs
    //{
    //    [XmlArray("WebRead")]
    //    [XmlArrayItem("ConnStr")]
    //    public List<ConnStr> WebReadList { get; set; }
    //    [XmlArray("Market")]
    //    [XmlArrayItem("ConnStr")]
    //    public List<ConnStr> MarketList { get; set; }
    //    [XmlArray("Main")]
    //    [XmlArrayItem("ConnStr")]
    //    public List<ConnStr> MainList { get; set; }
    //}
    [XmlRoot("connections")]
    public class ConnectionConfig
    {
        [XmlElement("connection")]
        public List<DataConnection> Items { set; get; }

        public DataConnection this[int index]
        {
            get { return Items[index]; }
        }

        public DataConnection this[string name]
        {
            get { return Items.Find(item => item.Name == name); }
        }
    }

    public class DataConnection
    {
        [XmlAttribute("name")]
        public string Name { set; get; }

        [XmlElement("connectionString")]
        public List<string> ConnectionStrings { set; get; }
    }

}
